package cn.b.training.baby_education_training.repository;

import cn.b.training.baby_education_training.entity.BabyNote;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @program: baby_education
 * @description
 * @author: wuying
 * @create: 2022-11-29 10:26
 **/
@Repository
public interface BabyNoteRepository extends JpaRepository<BabyNote,Long> {
    /**
     * 通过id获取日记信息
     * @param id
     * @return
     */
    @Query("select a from BabyNote a where a.id=?1")
    BabyNote getNoteById(Long id);

    @Query("select a from BabyNote a where a.babyId=?1")
    List<BabyNote> getNoteByBabyId(Long babyId);

    @Query("select a from BabyNote a where a.title LIKE CONCAT('%',?1,'%') ")
    List<BabyNote> getNoteByTitle(@Param("title") String title);
}
